package 简单的工厂模式.工厂模式demo.计算器;



/**
 * @author zyl
 * @Description
 * @since 2023/12/26 9:49
 */

public class OperationFactory {
    Operation operation = null;

    public Operation creatOperation(String operator){
        switch (operator){
            case "+":
                operation = new Add();
                break;
            case "-":
                operation = new Sub();
                break;
            case "*":
                operation = new Mul();
                break;
            case "/":
                operation = new Div();
                break;
        }
        return operation;
    }
}
